import * as React from 'react';
import { render } from '../../../renderers/factory';

export const schema = {
    title: "团队资料页",
    toolbar: {
        type: "button",
        actionType: "submit",
        label: "保存",
        icon: "fa fa-save pull-left",
        level: "primary",
        target: "theform"
    },
    body: {
        type: "form",
        mode: "horizontal",
        title: "",
        name: "theform",
        actions: [],
        initApi: "get:/api/user/team-acl?_=${1}",
        api: "post:/api/user/team-acl",
        controls: [
            {
                type: "radios",
                name: "join_type",
                label: "加入权限配置",
                value: "2",
                options: [
                    {
                        label: "免审加入",
                        value: "1"
                    },
                    {
                        label: "需要审核加入",
                        value: "2"
                    },
                    {
                        label: "不允许任何人加入",
                        disabled: true,
                        value: "3"
                    }
                ]
            },
            {
                children: (props, path) => {
                    const data = props.data;
                    console.info(data);
                    const t = render(`${path}/button`, {
                        type: 'button',
                        label: '取消绑定',
                        level: "danger",
                        // size: "xs",
                        actionType: "ajax",
                        confirmText: "确定要取消绑定？",
                        api: 'post:/api/bindwechat',
                        reload: 'theform'
                    }, props);
                    return (
                        <div className="form-group form-item" key="test">
                            <label className="col-sm-2 control-label">绑定微信推送设置</label>
                            <div className="col-sm-10">
                                <img style={{width:'230px', height:'230px'}} src="/api/bindwechat"/>
                                {
                                    data.user && data.user.open_id ?
                                        (
                                            <div style={{paddingLeft: '20px'}}>
                                                {t}
                                            </div>
                                        )
                                        :
                                        <div style={{paddingLeft: '20px'}}>用微信扫描二维码进行绑定</div>
                                }
                            </div>
                        </div>
                    );
                }
            }
        ]
    }
};
